package com.cz.nongyetongv5.custom;

import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;

public class BlueLoadingProgress extends AppCompatImageView {

	private AnimationDrawable animation = null;

	public BlueLoadingProgress(Context context) {
		super(context);

		animation = (AnimationDrawable) this.getBackground();

		startLoading();
	}

	public BlueLoadingProgress(Context context, AttributeSet attrs) {
		super(context, attrs);

		animation = (AnimationDrawable) this.getBackground();

		startLoading();
	}

	public BlueLoadingProgress(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);

		animation = (AnimationDrawable) this.getBackground();

		startLoading();
	}

	public void startLoading() {
		if (animation != null && !animation.isRunning()) {
			animation.start();
		}
	}

	public void stopLoading() {

		if (animation != null) {
			animation.stop();
		}

	}

}
